import React, { Component } from 'react'
import {Form, Input } from 'antd';

export default class EditForm extends Component {
    formRef = React.createRef();
    componentDidMount() {
        const { setFieldsValue } = this.formRef.current;
        setFieldsValue({
            joke_id: this.props.data.joke_id,
            joke_author: this.props.data.joke_author,
            joke_time: this.props.data.joke_time,
            joke_content: this.props.data.joke_content,
        });
        // this.props.form.setFieldsValue(this.props.data)
    }

    onChange=(date, dateString)=>{
        console.log(dateString);
        // this.setState({addTime:dateString})
    }

    render() {
        return (
            <Form ref={this.formRef}
                layout="horizontal"
                labelCol={{ span: 6}}//不能超过24
                wrapperCol={{ span: 12 }}
                >

                <Form.Item name="joke_id" label='编号'
                    rules={[{ readOnly: "true" }]}>
                    <Input disabled={true} />
                </Form.Item>

                <Form.Item name="joke_time" label='时间'>
                    <Input placeholder=''/>
                </Form.Item>
                <Form.Item name="joke_content" label='内容'
                    rules={[{ 
                            required: true,
                            message: '请输入内容',
                        }]}>
                    <Input.TextArea allowClear autoSize showCount maxLength={200} />
                </Form.Item>
            </Form>
        )
    }
}


// {
//     pattern:/\b1[358]\d{9}\b/g,
//     message:'请输入合法的电话号码',
// },
